package com.clkj.xiuzheng.dao;

import com.clkj.xiuzheng.pojo.UserShopApply;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface UserShopApplyMapper extends Mapper<UserShopApply> {

    @Select({"<script>",
            "SELECT s.apply_id, s.apply_money, s.apply_date, s.apply_status, s.user_id, u.user_name",
            "FROM t_cl_userShopApply s",
            "LEFT JOIN t_cl_user u ON s.user_id = u.user_id",
            "WHERE 1=1",
            "<if test='applyStatus != null'>",
            "AND s.apply_status = #{applyStatus}",
            "</if>",
            "<if test='userId != null'>",
            "AND u.user_id = #{userId}",
            "</if>",
            "order by s.apply_date desc",
            "</script>"})
    List<UserShopApply> listCommission(@Param("applyStatus") Integer applyStatus, @Param("userId") Integer userId);
}
